package com.zb_study.Homework01;

public class Homework01 {
    public static void main(String[] args) {
        Person[] persons = new Person[3];
        persons[0] = new Person("jack",10,"java");
        persons[1] = new Person("tom",20,"c++");
        persons[2] = new Person("smith",15,"python");

        for (int i = 0; i < persons.length; i++) {
            System.out.println(persons[i]);
        }

        Person temp = null;
        for (int i = 0; i < persons.length-1; i++) {
            for (int j = 0; j < persons.length-i-1; j++) {
                if(persons[j].getAge() < persons[j+1].getAge()) {
                    temp = persons[j];
                    persons[j] = persons[j+1];
                    persons[j+1] = temp;
                }
            }

        }
        System.out.println("============================");
        for (int i = 0; i < persons.length; i++) {
            System.out.println(persons[i]);
        }
    }
}
